home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-05 | 2.2 KB | 102 lines | [TEXT/MPS ] |
- /*
- File: mtb15.c
- Contains: Track Matte Functions
- Written by: DTS and QT Engineering
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
- Change History (most recent first):
- <1> 12/4/94 khs changed the format of the file to the new look and feel
- To Do:
- */
-
-
- // INCLUDES
- #include "mtb.h"
-
-
- // FUNCTIONS
- void CreateTrackMatte(Track theTrack)
- {
- QDErr err;
- GWorldPtr aGW;
- Rect trackBox;
- Fixed trackHeight;
- Fixed trackWidth;
- CTabHandle grayCTab;
-
- GetTrackDimensions(theTrack, &trackWidth, &trackHeight);
- SetRect(&trackBox, 0, 0, FixRound(trackWidth), FixRound(trackHeight));
-
- grayCTab = GetCTable(40); // 8 bit + 32 = 8 bit gray
- err = NewGWorld(&aGW, 8, &trackBox, grayCTab, (GDHandle)nil, 0);
- DisposeCTable(grayCTab);
- if (!err && (aGW != nil))
- {
- SetTrackMatte(theTrack, aGW->portPixMap);
- DisposeGWorld(aGW);
- }
- }
-
-
- void UpdateTrackMatte(Track theTrack)
- {
- OSErr err;
- PixMapHandle trackMatte;
- PixMapHandle savePortPix;
- Movie theMovie;
- GWorldPtr tempGW;
- CGrafPtr savePort;
- GDHandle saveGDevice;
- Rect matteBox;
- short i;
-
- theMovie = GetTrackMovie(theTrack);
- trackMatte = GetTrackMatte(theTrack);
- if (trackMatte == nil)
- {
- // track doesn't have a matte, so give it one
- CreateTrackMatte(theTrack);
- trackMatte = GetTrackMatte(theTrack);
- if (trackMatte == nil)
- return;
- }
-
- GetGWorld(&savePort, &saveGDevice);
- matteBox = (**trackMatte).bounds;
- err = NewGWorld(&tempGW, (**trackMatte).pixelSize, &matteBox, (**trackMatte).pmTable, (GDHandle)nil, 0);
- if (err || (tempGW == nil))
- return;
-
- SetGWorld(tempGW, nil);
- savePortPix = tempGW->portPixMap;
- LockPixels(trackMatte);
- SetPortPix(trackMatte);
-
- // draw a gray ramp rectangle around the edge of the matte
- for (i = 0; i < 35; i++)
- {
- RGBColor aColor;
- long tempLong;
-
- tempLong = 65536 - ((65536 / 35) * (long)i);
- aColor.red = aColor.green = aColor.blue = tempLong;
- RGBForeColor(&aColor);
- FrameRect(&matteBox);
- InsetRect(&matteBox, 1, 1);
- }
-
- // fill the center of the matte with black
- ForeColor(blackColor);
- PaintRect(&matteBox);
-
- SetPortPix(savePortPix);
- SetGWorld(savePort, saveGDevice);
- DisposeGWorld(tempGW);
-
- UnlockPixels(trackMatte);
- SetTrackMatte(theTrack, trackMatte);
-
- DisposeMatte(trackMatte);
- }
-
-
-